package com.twu.biblioteca;

public class Movie extends LibraryItem {
    private final String director;
    private final int rating;

    public Movie(String title, String director, String year, int rating) {
        super(title, year);
        this.director = director;
        this.rating = rating;
    }

    public String getDirector() {
        return director;
    }

    public int getRating() {
        return rating;
    }

    @Override
    public String toString() {
        String ratingString = "";
        if (rating > 0 && rating <= 10)
            ratingString += rating;
        else
            ratingString = "unrated";

        return "Title: '" + this.getTitle() + "'" + Book.LIST_SEPARATOR +
                "Director: '" + this.director + "'" + Book.LIST_SEPARATOR +
                "Year: '" + this.getYearPublished() + "'" + Book.LIST_SEPARATOR +
                "Rating: '" + ratingString + "'";

    }

    public boolean compareWithDetails(String title, String director, String year) {  //TODO Clarify whether a different rating means a different film
        return (this.getTitle().equalsIgnoreCase(title) &&
                this.getDirector().equalsIgnoreCase(director) &&
                this.getYearPublished().equalsIgnoreCase(year));
    }
}
